package com.zhaohanlin.start;

import org.junit.Test;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Random;

import static java.lang.reflect.Array.*;

/**
 * @author zhaohanlin
 */

public class TestsSix {

    // * 输出数字串"18210210122"中的最大数字"8"和最小值数字"0"
    // */

    @Test
    public void add() {
        String str = "18210210122";
        char[] chars = str.toCharArray();
        Arrays.sort(chars);
        System.out.println(chars[0]);
        System.out.println(chars[chars.length - 1]);
    }

    //题目： 求数组：{1, 3, 5, 7, 9, 2, 4, 6, 8, 0}，的最小值，最大值和平均值。
    @Test
    public void add1() {
        int[] arrA = {1, 3, 5, 7, 9, 2, 4, 6, 8, 0};
        int max = arrA[0], min = arrA[0], length = arrA.length;
        double ave = 0;
        for (int i = 0; i < length; i++) {
            if (max < arrA[i]) {
                max = arrA[i];
                if (min > arrA[i]) {
                    min = arrA[i];

                }
                ave += arrA[i];
            }

        }
        System.out.println("最小值" + min);
        System.out.println("最大值" + max);
        System.out.println("平均数" + ave);
    }

    //某公司按照季度和月份统计的数据如下，单位（万元）
    @Test
    public void add2() {
        int r = 0;
        int[] arrA = {22, 66, 44, 77, 33, 88, 25, 45, 65, 11, 66, 99};
        int length = arrA.length;
        System.out.println("公司第一季度收入为：22万，66万，44万");
        for (int i = 0; i < length; i++) {
            r += arrA[i];

        }
        System.out.println("年度销售" + r + "万元");


    }

    @Test
    public void man() {
        int[] arrA = {22 + 66 + 44 + 77 + 33 + 88 + 25 + 45 + 65 + 11 + 66 + 99};
        System.out.print("总和为：");
        System.out.println(22 + 66 + 44 + 77 + 33 + 88 + 25 + 45 + 65 + 11 + 66 + 99 + "万元");
    }

    @Test
    public void add3() {

    }
}

